<%@page import="com.huixue.cn.ztej.constants.ResourceLocator"%>
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/static/common/default.jsp"%>
<!DOCTYPE html>
<html lang="en">
	 <head>
	 <jsp:include page="/style/header.jsp"></jsp:include>
	 </head>
	 <body>
	 
	 <div class="title_bar">
        <h3>零星机械申请</h3>
        <!-- <a href="javascript:history.go(-1);" class="go_back"></a> -->
     </div>
     <div class="apply">
     	<div class="ipt_title">基本信息</div>
     	<div class="ipt_list">
     		<div class="ipt_cell">
                <span class="tag">签证编号</span>
                <span>${res.visaCode}&nbsp;</span>
            </div>
     		
            <div class="ipt_cell">
                <span class="tag">项目名称</span>
                <span>${res.project.name}&nbsp;</span>
            </div>
            
            <div class="ipt_cell">
                <span class="tag">里程桩号</span>${res.mileageCode}&nbsp;
            </div>
            
            <div class="ipt_cell">
                <span class="tag">用工内容</span>${res.applyContent}&nbsp;
            </div>
            
            <div class="ipt_cell">
                <span class="tag">工程类别</span>
                <c:choose>
                	<c:when test="${res.projectId==1}">路基</c:when>
                	<c:when test="${res.projectId==2}">路面</c:when>
                	<c:when test="${res.projectId==3}">桥涵</c:when>
                	<c:when test="${res.projectId==4}">隧道</c:when>
                	<c:when test="${res.projectId==5}">其他</c:when>
                </c:choose>
            </div>
           
            <div class="ipt_cell">
                <span class="tag">机械类型</span>${res.mechanical.mechanicalName}&nbsp;
            </div>
            
            <div class="ipt_cell">
                <span class="tag">机械型号</span>${res.mechanical.mechanicalModel}&nbsp;
            </div>
            
            <div class="ipt_cell">
                <span class="tag">使用开始时间</span>
                <fmt:formatDate value="${res.startTime}" type="both" pattern="yyyy-MM-dd HH:mm"/>&nbsp;
            </div>
            
            <div class="ipt_cell">
                <span class="tag">使用结束时间</span>
                <fmt:formatDate value="${res.endTime}" type="both" pattern="yyyy-MM-dd HH:mm"/>&nbsp;
            </div>
            
            <div class="ipt_cell">
                <span class="tag">租用项目机械</span>
                <c:choose>
                <c:when test="${res.rent==1}">否</c:when>
                <c:when test="${res.rent==2}">是</c:when>
                </c:choose>&nbsp;
            </div>
            
            <div class="ipt_cell">
                <span class="tag">使用工时</span>${res.useHours}&nbsp;
            </div>
            
            <div class="ipt_cell">
                <span class="tag">扣除时间</span>${res.deductHour}&nbsp;
            </div>
            
            <div class="ipt_cell">
                <span class="tag">机械单价</span>
            	<input type="text" value="${res.price}" id="price" name="price" style="color: #000000">
            </div>
            
            <div class="ipt_cell">
                <span class="tag">台数</span>${res.quantity}&nbsp;
            </div>
            
            <div class="ipt_cell">
                <span class="tag">费用</span>${res.fee}&nbsp;
            </div>
            
            <div class="ipt_cell">
                <span class="tag">施工队</span>${res.team.name}&nbsp;
            </div>
                        
            <div class="ipt_cell">
                <span class="tag">状态</span>
                <c:choose><c:when test="${res.state==0}">已发起</c:when>
                <c:when test="${res.state==3}">物资部已审批</c:when>
                <c:when test="${res.state==4}">工段已审批</c:when>
                <c:when test="${res.state==5}">计划部已审批</c:when>
                <c:when test="${res.state==6}">已完成</c:when>
                <c:when test="${res.state==-3}">物资部审批未通过</c:when>
                <c:when test="${res.state==-4}">工段审批未通过</c:when>
                <c:when test="${res.state==-5}">计划部已取消</c:when>
                <c:when test="${res.state==-6}">项目经理审批未通过</c:when>
                </c:choose> 
            </div>
            
            <div class="ipt_cell">
                <span class="tag">申请时间</span>
                <fmt:formatDate value="${res.applyTime}" type="both" pattern="yyyy-MM-dd HH:mm"/>
            </div>
            
            <div class="ipt_cell">
                <span class="tag">申请人</span>${res.user.userName}&nbsp;
            </div>
            
            <div class="ipt_cell" style="border: none;">
                <span class="tag">附加照片</span>
                <div class="tip">前、中、后三张</div>
            </div>
 
            <div class="img_upload">
            <span class="add_img"><img data-preview-src="" data-preview-group="1" src="<%=ResourceLocator.getResourceBrowseUrl(request) %>${res.frontImage}" alt="" height="130px"></span>
            <span class="add_img"><img data-preview-src="" data-preview-group="1" src="<%=ResourceLocator.getResourceBrowseUrl(request) %>${res.middleImage}" alt="" height="130px"></span>
            <span class="add_img"><img data-preview-src="" data-preview-group="1"src="<%=ResourceLocator.getResourceBrowseUrl(request) %>${res.behindImage}" alt="" height="130px"></span>
            </div>
           
     	</div>
     	
        <div class="ipt_title">审批详情</div>
     	<c:forEach var="list" items="${examineList}">
     	<div class="ipt_list hour_cell">
	     	<div class="ipt_cell">
	                <span class="tag">审批人:</span>${list.examineName}&nbsp;
	        </div>
	     	<div class="ipt_cell">
	                <span class="tag">审批时间:</span><fmt:formatDate value="${list.examineTime}" type="both" pattern="yyyy-MM-dd HH:mm"/>&nbsp;
	        </div>
	        <div class="ipt_cell">
	                <span class="tag">审批内容:</span>${list.content}&nbsp;
	        </div>
	        <div class="ipt_cell">
	                <span class="tag">备注:</span>${list.examineRemark}&nbsp;
	        </div>
        </div>
        </c:forEach>
        
        <c:choose>
        	<c:when test="${user.roleId eq 4 && res.state==0}">
        		<div class="ipt_title">审批备注</div>
        		<div class="ipt_list">
        		<div class="ipt_cell">
	                <span class="tag">备注:</span>
	                <input type="text" placeholder="可填写备注说明" id="approveRemark">
	        	</div>
	        	</div>
            	<div class="btn_box">
            		<div class="btn" id="approve" data-type="2" data-status="4">同 意</div>
            		<div class="btn btn3" id="noapprove" data-type="2" data-status="-4">不同意</div>
            	</div> 
            </c:when>
            <c:when test="${user.roleId eq 3 && res.state==4}">
            	<div class="ipt_title">审批备注</div>
            	<div class="ipt_list">
        		<div class="ipt_cell">
	                <span class="tag">备注:</span>
	                <input type="text" placeholder="可填写备注说明" id="approveRemark">
	        	</div>
	        	</div>
            	<div class="btn_box">
            		<div class="btn" id="approve" data-type="2" data-status="3">同 意</div>
            		<div class="btn btn3" id="noapprove" data-type="2" data-status="-3">不同意</div>
            	</div> 
            </c:when>	
            <c:when test="${user.roleId eq 5 && res.state==3}">
            	<div class="ipt_title">审批备注</div>
            	<div class="ipt_list">
        		<div class="ipt_cell">
	                <span class="tag">备注:</span>
	                <input type="text" placeholder="可填写备注说明" id="approveRemark">
	        	</div>
	        	</div>
            	<div class="btn_box">
            		<div class="btn" id="approve" data-type="2" data-status="5">同 意</div>
            		<div class="btn btn3" id="noapprove" data-type="2" data-status="-5">不同意</div>
            	</div> 
            </c:when>
            <c:when test="${user.roleId eq 6 && res.state==5}">
            <div class="ipt_title">审批备注</div>
            	<div class="ipt_list">
        		<div class="ipt_cell">
	                <span class="tag">备注:</span>
	                <input type="text" placeholder="可填写备注说明" id="approveRemark">
	        	</div>
	        	</div>
            	<div class="btn_box"><div class="btn" id="approve" data-type="2" data-status="6">同 意</div>
            	<div class="btn btn3" id="noapprove" data-type="2" data-status="-6">不同意</div></div> 
     		</c:when>
     	</c:choose>
     	
     	<c:if test="${user.roleId eq 2  && (res.state==0||res.state==3||res.state==4||res.state==5)}">
     	<div class="ipt_title">当前审批人</div>
     	<div class="ipt_list hour_cell">
	     	<div class="ipt_cell">
	                <span class="tag">审批人:</span>${nextApprovUser.userName}&nbsp;
	        </div>
	     	<div class="ipt_cell">
	                <span class="tag">电话:</span>${nextApprovUser.phoneNum}&nbsp;
	        </div>
	       
       	</div>
     	</div>
     	</c:if>
     </div><br/>
     
     <jsp:include page="/style/footer.jsp"></jsp:include>
     <script type="text/javascript">
     $('#approve').click(function() {    	 
    	 var status = jQuery("#approve").data('status');
    	 var type = jQuery("#approve").data('type');
    	 var approveRemark = jQuery("#approveRemark").val();
    	 var price = jQuery("#price").val();
    	 var approve_data = {
    		'applyType': type,
    		'status':status,
    		'applyId':"${res.applyId}",
    		'approveUserId':"${user.user_id}",
    		'approveLoginName':"${user.loginName}",
    		'approveUserName':"${user.userName}",
    		'approveRemark':approveRemark,
    		'price':price
         }
    	 loading_show(); 
    	 $.ajax({
  	        async: true,
  	        type:"POST",
  	        data:JSON.stringify(approve_data),
  	        
  	        url: "${ctx}/approve/todo?mid="+Math.random(),
  	        dataType: "json",
  	        headers : {  
            	'Content-Type' : 'application/json;charset=utf-8'  
            },
              
            success : function(data) {
            	loading_hide(500);
          		if (data != undefined && data.status != undefined
          				&& data.status.trim() == '0') {
          			window.location.href = "${ctx}/approve/success";
          			tiper(data.error,'green');
          			result = true;
          		} else {
          			result = false;
          			tiper(data.error);
          		}
          	},
  		},"json") 
     });
     
     $('#noapprove').click(function() {    	 
    	 var status = jQuery("#noapprove").data('status');
    	 var type = jQuery("#noapprove").data('type');
    	 var approveRemark = jQuery("#approveRemark").val();
    	 var price = jQuery("#price").val();
    	 var approve_data = {
    		'applyType': type,
    		'status':status,
    		'applyId':"${res.applyId}",
    		'approveUserId':"${user.user_id}",
    		'approveLoginName':"${user.loginName}",
    		'approveUserName':"${user.userName}",
    		'approveRemark':approveRemark,
    		'price':price
         }
    	 loading_show(); 
    	 $.ajax({
  	        async: true,
  	        type:"POST",
  	        data:JSON.stringify(approve_data),
  	        url: "${ctx}/approve/todo?mid="+Math.random(),
  	        dataType: "json",
  	        headers : {  
            	'Content-Type' : 'application/json;charset=utf-8'  
            },
              
            success : function(data) {
            	loading_hide(500);
          		if (data != undefined && data.status != undefined
          				&& data.status.trim() == '0') {
          			window.location.href = "${ctx}/approve/success";
          			result = true;
          		} else {
          			result = false;
          			tiper(data.error);
          		}
          	},
  		},"json")
     });
     
     $('input').prop('disabled', true);
     $('#approveRemark').prop('disabled', false);
     if(${user.roleId}== 5 && ${res.state}==3){
    	 $('#price').prop('disabled', false);
     }
     //
     //$('#price').prop('disabled', false);
     
     $("#price").change(function(){
    	 //var price = $('#price').val();
    	 //var price = $('#price').val();
     });
     mui.previewImage();
     </script>
	 </body>
</html>